/*
 * @Author: jinye.zhang
 * @Version: 1.0.0
 * @Date: 2021-04-25 09:00:54
 * @LastEditors: jinye.zhang
 * @LastEditTime: 2021-07-12 11:38:06
 * @Description: 
 */
import Vue from 'vue'
export function commonShare() {
	//监听路由切换
	//间接实现全局设置分享内容
	// #ifdef MP
	uni.onAppRoute(function (res) {
		//获取加载的页面
		let pages = getCurrentPages(),
			//获取当前页面的对象
			view = pages[pages.length - 1];
			if (view && view.route !== 'pages/author/detail' && view.route !== 'pages/artworks/artworksSquareDetails' && view.route !== 'pages/artworks/videoWallpaperDetails' && view.route !== 'pages/artworks/wallpaperDetails') {
				view.onShareAppMessage = function (res) {
				//分享配置
				return {
					title: `${Vue.prototype.$store.state.userInfo.user_name || ''}邀请您${Vue.prototype.$store.state.appletInfo.describe}${Vue.prototype.$store.state.userInfo.invitation_code}`,
      		desc: `${Vue.prototype.$store.state.userInfo.user_name || ''}邀请您${Vue.prototype.$store.state.appletInfo.describe}${Vue.prototype.$store.state.userInfo.invitation_code}`,
					path: `/pages/index/index?source_code=${Vue.prototype.$store.state.userInfo.invitation_code}`,
					success: (res) => {
					}
				};
			}
		} else {
      view.onShareAppMessage = function (res) {
      //分享配置
      return {
        title: `${Vue.prototype.$store.state.userInfo.user_name || ''}邀请您${Vue.prototype.$store.state.appletInfo.describe}`,
        desc: `${Vue.prototype.$store.state.userInfo.user_name || ''}邀请您${Vue.prototype.$store.state.appletInfo.describe}`,
        }
      };
    }
	})
	// #endif
}